﻿@using SCMS.Resource
@model SCMS.Model.AttachedDocument
@{AjaxOptions ajaxOpts = new AjaxOptions
  {
      UpdateTargetId = "PODiv",
      LoadingElementId = "loading",
      HttpMethod = "Post",
      Url = Url.Action("SubmitPO"),
      OnSuccess = "javascript:usermsg('Purchase Order Submitted for Approval'); if (document.getElementById('table') != null) {initSorter();sorter.size(50);}",
      Confirm = Resources.Global_String_SubmitForReview + "?"

  };}
<script src="@Url.Content("~/Scripts/js/modalite.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div class="partialViewCard">
    <div class="partialViewCardHeader">
        <h3>@Resources_morgan.Global_String_AttacheDocuments</h3>
    </div>
    <br />
    <center>
        @Ajax.ActionLink(Resources_morgan.Global_String_AddAttachment, "AttachNewDoc", new { docId = Model.POEntity.Id }, new AjaxOptions
   {
       UpdateTargetId = "popup-page",
       LoadingElementId = "popup-loading",
       HttpMethod = "Post",
       OnBegin = string.Format("ShowDialogue('{0}')", Resources_morgan.Global_String_AddAttachment),
       OnSuccess = "initFineFileUploader('/GoodsReceivedNote/HandleImageUpload');CenterPopup();"

   })
    </center>
    @using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
    {
        @Html.ValidationSummary(true)
        <br />
        @Html.HiddenFor(x => x.POEntity.Id)

        <table width="96%" align="center" cellpadding="0" cellspacing="0" border="0" id="table"
            style="margin-left: auto; margin-right: auto;" class="tinytable">
            <tr class="gridheader">
                <th>
                    @Resources.Global_String_RefNo
                </th>
                <th>
                    @Resources_morgan.Global_String_DocumetName
                </th>
                <th>
                    @Resources_morgan.PurchaseOrder_AttachNewDoc_FileType
                </th>
                <th align="center">
                    @Resources.Global_String_Manage
                </th>
            </tr>
            @foreach (var item in Model.DocList)
            {
                <tr>
                    <td valign="top" style="width: 20%;" align="left">
                        <a  href="@Url.Action("Getattachment", "PurchaseOrder", new { docId = item.Id })" target="_blank" style="margin-left: 48%; margin-bottom: 2%;">@item.RefNo</a>
                    </td>
                    <td>@item.Name
                    </td>
                    <td style="width: 20%;">@item.FileType
                    </td>
                    <td align="center" style="width: 15%;">
                        @Ajax.ActionLink(Resources.Global_String_Edit, "AttachNewDoc", new { docId = Model.POEntity.Id, attachedDocId = item.Id }, new AjaxOptions
                   {
                       UpdateTargetId = "popup-page",
                       LoadingElementId = "popup-loading",
                       HttpMethod = "Post",
                       OnBegin = string.Format("ShowDialogue('{0}')", Resources.Global_String_Edit),
                       OnSuccess = "initFineFileUploader('/GoodsReceivedNote/HandleImageUpload');CenterPopup();"

                   })
                        &nbsp;|&nbsp;
                        @Ajax.ActionLink(Resources.Global_String_Delete, "DeleteAttachedDoc", new { attachedDocId = item.Id, docId = Model.POEntity.Id }, new AjaxOptions
                   {
                       UpdateTargetId = "PODiv",
                       LoadingElementId = "loading",
                       Confirm = string.Format(Resources.Global_String_ConfirmDelete, item.Name)//,
                       // OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(20);}"
                   })
                    </td>
                </tr>
            }
        </table>
        <hr />
        <table width="98%" align="center">
            <tr>
                <td width="50%">
                    @Ajax.ActionLink("<<" + Resources.Global_String_Back, "Load2ndLastStep", new { poId = Model.POEntity.Id }, new AjaxOptions
               {
                   UpdateTargetId = "PODiv",
                   LoadingElementId = "loading"
               })
                </td>
                <td align="right" width="50%">
                    @Html.HiddenFor(p => p.POEntity.Id)
                    <input type="submit" class="btn green" value="@Resources.Global_String_SubmitForReview" />
                </td>
            </tr>
        </table>
        <input type="hidden" id="currencyId" value="@Model.POEntity.CurrencyId" />
    }
</div>
